﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DataAccess;
using DataAccess.Classes;
namespace Webmau.Controls
{
    public partial class DiaDiem : System.Web.UI.UserControl
    {
        string idDiaDiem = "";
        protected void Page_Load(object sender, EventArgs e)
        {
           // idDiaDiem = Request.QueryString["ID"];
            if (!IsPostBack)
                LayDanhSachDiaDiem();
        }
        private void LayDanhSachDiaDiem()
        {
            repDiaDiem.DataSource = DiaDiem1.LayDanhSachTheoTinhTrang();
            repDiaDiem.DataBind();
        }
        protected void repDiaDiem_ItemCommand(object source, RepeaterCommandEventArgs e)
        {

        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            repDiaDiem.ItemDataBound += new RepeaterItemEventHandler(repDiaDiem_ItemDataBound);
        }
        void repDiaDiem_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                DiaDiem1 data = e.Item.DataItem as DiaDiem1;
                string id = data.ID.ToString();

                HyperLink lnkDiaDiem = (HyperLink)e.Item.FindControl("lnkDiaDiem");
                lnkDiaDiem.Text = data.TenDiaDiem;
                lnkDiaDiem.NavigateUrl = Link.ToDiaDiem(id);

                lnkDiaDiem.CssClass = id == idDiaDiem ? "current" : "";
                lnkDiaDiem.ToolTip = data.ThongTin;
            }
        }

        
    }
}
